package com.jy.adscm.hcPlan.controller;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.jy.adscm.exception.AdscmSystemException;
import com.jy.adscm.hcPlan.bean.HcPlanMaterielPrice;
import com.jy.adscm.hcPlan.service.HcPlanMaterielPriceService;
import com.jy.adscm.support.SimpleCoreResponse;
import com.jy.adscm.utils.AdscmDateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 物料采购财务报表 前端控制器
 * </p>
 *
 * @author yyy
 * @since 2018-08-24
 */
@RestController
@RequestMapping("/adscm/hcplan/materielPrice")
public class HcPlanMaterielPriceController {


    @Autowired
    HcPlanMaterielPriceService hcPlanMaterielPriceService;

    /**
     * 装载指定的合并的物料对应的财务报表
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/loadMaterielPrice/{merge_id}")
    public SimpleCoreResponse loadMaterielPrice(@PathVariable String merge_id) throws AdscmSystemException {

        hcPlanMaterielPriceService.loadMaterielPrice(merge_id);
        return new SimpleCoreResponse("200","装配成功",null);
    }
    /**
     * 查询所有财务报表
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/getAllMaterielPrice")
    public SimpleCoreResponse getAllMaterielPrice() throws AdscmSystemException {

        Wrapper<HcPlanMaterielPrice> wrapper = new EntityWrapper<>();
        wrapper.orderBy("materiel_purchase_time",false);

        return new SimpleCoreResponse("200","查询成功",hcPlanMaterielPriceService.selectList(wrapper));
    }
    /**
     * 提交财务报表审核
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/submitAudit/{audit_status}")
    public SimpleCoreResponse submitAudit(@RequestParam(value = "mergeIds[]") String[] mergeIds,@PathVariable Integer audit_status) throws AdscmSystemException {

        hcPlanMaterielPriceService.submitAudit(mergeIds,audit_status);

        return new SimpleCoreResponse("200","提交财务报表审核成功",null);
    }
    /**
     * 获取预计消费
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/getTheWeekPlanPrice")
    public SimpleCoreResponse getTheWeekPlanPrice(@RequestParam(value = "mergeIds[]") String[] mergeIds) throws AdscmSystemException {


        return new SimpleCoreResponse("200","获取预计消费成功",hcPlanMaterielPriceService.getTheWeekPlanPrice(mergeIds));
    }



}

